<?php
require_once '../../includes/global.php';
//error_reporting(7);
$wcfg=Dga('wcfg',"web like '".$sitename."' and lg like '".$_SESSION[LG]."'");
$wcfg=json_decode($wcfg[wcfg],true);

$webconfig[lgconfig]=$wcfg['lang'];
$webconfig[num]=$wcfg['num'];

$priceInfo=Dga('infosort',"del!=1 and id='".$_GET['bdsortid']."'");


function getCar($pgs,$openSeach=1,$seachForm,$threeDay){
	$newTable	=	new xajaxResponse();
	/**
	 * ******************
	 * 是否进行搜索加的条件
	 * 不是搜索的话，就看$openSeach里是不是有要点击搜索的东西
	 * 
	 * 不进行搜索的入口-->$notfind<--一个数组,写进去就行
	 * 对时间搜索
	 */
	
	$notfind = array(//不进行搜索的数组
		1 => 'showNum',
		2=>'paixu'
		);
	
	if ($openSeach==1){
		if ($seachForm['seachDate']!=''){
			$seachForm['seachDate']=strtotime($seachForm['seachDate']);//将时间搜索转换为时间戳[下面还要转换回来  ^_^!]
			$seachCondition=" and actdate > '".$seachForm['seachDate']."' and actdate < '".($seachForm['seachDate']+INT_DAY)."'";
			$seachForm['seachDate']=date("Y-m-d",$seachForm['seachDate']);//再换回来
		}
		foreach ($seachForm as $seachFormKey => $seachFormVal){
			if (!in_array($seachFormKey,$notfind)){//不进行搜索的条件
				if ($seachFormKey=='seachQujianDateStart' && $seachFormVal!=''){
					//区间搜索
					$xxttyxo=strtotime($seachFormVal);
					$seachCondition.=" and actdate > '$xxttyxo'";
				}else if ($seachFormKey=='seachQujianDateStop' && $seachFormVal!=''){
					//区间搜索
					$xxttyxo=strtotime($seachFormVal);
					$seachCondition.=" and actdate < '$xxttyxo'";
				}else if ($seachFormKey=='jingjian'){
					//精简设置
					//$newTable->alert('b');
					if (trim($seachFormVal)=='jingjian'){
						$jingjianCheck='checked';
						$seachCondition.=" and content != '' ";
					}else{
						$jingjianCheck='';
					}
				}else {
					$seachFormKey!='mohu'?//不进行模糊的input->checkbox的搜索
						($seachForm['mohu']!='checked'?//是否进行模糊搜索
							(
								$seachFormKey!='seachDate'?//是否搜索时间字段
									(
										trim($seachFormVal)!=''?$seachCondition.=" and $seachFormKey like '$seachFormVal'"
										:
											'')
									:
										'')
						:(
							$seachFormKey!='seachDate'?//是否搜索时间字段
								(trim($seachFormVal)!=''?$seachCondition.=" and $seachFormKey like '%".$seachFormVal."%'":'')
							:
								'')
					)
					:
						'';
				}
		}
		}
	}else {
		unset($seachForm);//先把老搜索栏的东西给清除
		$hitSeach=explode(',',$openSeach);
		foreach ($hitSeach as $hitKey=>$hitValue){
			if (!strrpos($hitValue,'=')===false){
				$valSeach=explode('=',$hitValue);
				if($valSeach!='' && $valSeach!=0 && is_array($valSeach)){
					$seachForm[$valSeach[0]]=$valSeach[1];
					$seachCondition.=" and $valSeach[0] like '$valSeach[1]'";
				}
			}
		}
	}
//		$newTable->alert($seachCondition);
//		$newTable->alert($seachForm[mohu]);
	//ajax分页的获取
	if ($pgs!=''){
		$tmppg=explode('&',$pgs);
		if (is_array($tmppg)){
			foreach ($tmppg as $ttp){
				$tmppgn=explode('=',$ttp);
				($tmppgn[0]=='seachpage')?$_GET['seachpage']=$tmppgn[1]:'';
			}
		}
	}
	//项目下拉的默认
	switch ($seachForm['xiangmu']){
		case '接机':
			$jieji='SELECTED';
			break;
		case '送机':
			$songji='SELECTED';
			break;
		case '旅游':
			$lvyou='SELECTED';
			break;
		case '其他':
			$qita='SELECTED';
			break;
		default:
			$suoyou='SELECTED';
			break;
	}
	//收费下拉的默认
	switch ($seachForm['shoufei']){
		case '标准':
			$biaozhunS='SELECTED';
			break;
		case '收费':
			$shoufeiS='SELECTED';
			break;
		case '免费':
			$mianfeiS='SELECTED';
			break;
		default:
			$suoyous='SELECTED';
			break;
	}
	//排序下拉的默认	
	if($seachForm['paixu']==''){
		if($_SESSION['paixu']==''){
			$seachForm['paixu']=13;
			$_SESSION['paixu']=$seachForm['paixu'];//初始化session
		}else{
			$seachForm['paixu']=$_SESSION['paixu'];
		}
	}else{
		$_SESSION['paixu']=$seachForm['paixu'];//初始化session
	}
	$seachForm[paixu]=$_SESSION['paixu'];
	switch ($seachForm['paixu']){
		case 'id':
			$idzhengxu='SELECTED';
			break;
		case 'id desc':
			$iddaoxu='SELECTED';
			break;
		case 'actdate':
			$actzhengxu='SELECTED';
			break;
		case 'actdate desc':
			$actdaoxu='SELECTED';
			break;
		default:
			$seachForm[paixu]='id desc';//默认排序
			$paixumoren='SELECTED';
			break;
	}
	
	/**
	 * *****************************************
	 * 緩存
	 */
	ob_start();
	
	
	//配置搜索		
	//$condition.=" and userid = '".$_."'(prodtype,".$_GET[sortid]."')>0";
	$condition.=" ".$seachCondition;
	$sql="SELECT count(id) as num
	FROM lm_car_dispatch
	where 1  and del!=1 ".$condition;
	$res=mysql_query($sql);
	$temp=mysql_fetch_array($res);
	//每页
	//用session记录下用户最后一次选的查看一页几条信息
	if($seachForm['showNum']==''){
		if($_SESSION['showNum']==''){
			$seachForm['showNum']=13;
			$_SESSION['showNum']=$seachForm['showNum'];//初始化session
		}else{
			$seachForm['showNum']=$_SESSION['showNum'];
		}
	}else{
		$_SESSION['showNum']=$seachForm['showNum'];//初始化session
	}
	$pageline=$seachForm['showNum'];
	
	!$_GET['seachpage']&&$_GET['seachpage']=1;
	$ajaxpage=new lm_page(array('total'=>$temp[num],'perpage'=>$pageline,'page_name'=>'seachpage','ajax'=>'getCar'));
	mysql_free_result($res);
	
	
	/**
	 * ********************************
	 * 是否开启3天用车
	 */
	if ($threeDay!=1){//不是3天的就显示那条东西
		$allNum=$temp[num];
		$nav=$ajaxpage->show(1);
		$seachStatus=<<<EQT
			--
			<a href="javascript:void(0);" onclick="getCar('seachpage=$_GET[seachpage]',1);" title="刷新本页">[刷新]</a>
			--
			搜索到[<span style="color:#FD6907;">$allNum</span>]条数据,每页显示[<input name="showNum" type="text" onclick="this.select();" onchange="getCar('',1);" value="$pageline"  style="width:21px;text-align:center"/>]条.
			
			
EQT;
		$delNav=<<<EQT
		
	  		<div styel="clear:both;">
			  <span style="float:left;">
				  ┕┅┅┉
				  [<a href="javascript:void(0);" style="font-size:11px;" onclick='chkall("selectForm")'><span id="actselect" >全(选中)</span></a>]
				  ┅┅┅┅┅
				  <a href="javascript:void(0);" onclick="if(confirm('您确定要批量删除吗?')){delAll('selectForm');return false;}else{return false;}">删除</a>
			  </span>
	  		<div style="text-align:right;">$nav</div>
		  </div>
EQT;
	}


	
	echo <<<EQT
		<div>
		<form id="searchCar" name="searchCar" action="javascript:void(0);" method="post" onSubmit="getCar('seachpage=1',1);">
			<span style="float:right;">
				<span><input id="mohu" name="mohu" type="checkbox" $seachForm[mohu] value="checked"/><label for="mohu">模糊</label></span>
				<span><input id="jingjian" name="jingjian" type="checkbox" $jingjianCheck onClick="getCar('seachpage=$_GET[seachpage]',1);" value="jingjian"/><label for="jingjian">精减</label></span>
				<br />
				<span><input type="button" value="清空" onclick="clearInp('searchCar','showNum');" /><input type="submit" value="搜索"/></span>
			</span>
			<span id="seachFormSpan33" style="width:80%;display:inline;float:left;clear:right;">
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachDate">时间</label><input id="seachDate" type="text" name="seachDate"onfocus="WdatePicker({dateFmt:'yyyy-M-d',vel:'d244_2'})" size="20" class="Wdate" style="height:14px;"  value="$seachForm[seachDate]" style="width:100px;"/></span>
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachDate2">&nbsp;&nbsp;&nbsp;&nbsp;区间搜索</label><input id="seachDate2" type="text" name="seachQujianDateStart"onfocus="WdatePicker({dateFmt:'yyyy-M-d',vel:'d244_2'})" size="20" class="Wdate" style="height:14px;"  value="$seachForm[seachQujianDateStart]" style="width:100px;"/></span>
				<span style="display:block;white-space:nowrap;"><label for="seachDate3">至 </label><input id="seachDate3" type="text" name="seachQujianDateStop"onfocus="WdatePicker({dateFmt:'yyyy-M-d',vel:'d244_2'})" size="20" class="Wdate" style="height:14px;"  value="$seachForm[seachQujianDateStop]" style="width:100px;"/></span>
				
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachKehu">客户</label><input id="seachKehu" type="text" name="name" value="$seachForm[name]" style="width:100px;"/></span>
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachTel">电话</label><input id="seachTel" type="text" name="tel" value="$seachForm[tel]" style="width:100px;"/></span>
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachChengshi">城市</label><input id="seachChengshi" type="text" name="chengshi" value="$seachForm[chengshi]" style="width:100px;"/></span>
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachHotel">酒店</label><input id="seachHotel" type="text" name="hotel" value="$seachForm[hotel]" style="width:100px;"/></span>
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachSiji">司机</label><input id="seachSiji" type="text" name="siji" value="$seachForm[siji]" style="width:100px;"/></span>
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachChexing">车型</label><input id="seachChexing" type="text" name="chexing" value="$seachForm[chexing]" style="width:100px;"/></span>
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachUserid">预定员</label><input id="seachUserid" class="sssssss" type="text" name="userid" value="$seachForm[userid]" style="width:100px;" /></span>
				
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachShoufei">收费</label>
					<select id="seachShoufei" name="shoufei">
						<option $suoyouS value="">所有</option>
						<option $biaozhunS value="标准">标准</option>
						<option $shoufeiS value="收费">收费</option>
						<option $mianfeiS value="免费">免费</option>
					</select>
				</span>
				<span style="float:left;display:block;white-space:nowrap;"><label for="seachXiangmu">项目</label>
					<select id="seachXiangmu" name="xiangmu">
						<option $suoyou value="">所有</option>
						<option $jieji value="接机">接机</option>
						<option $songji value="送机">送机</option>
						<option $lvyou value="旅游">旅游</option>
						<option $qita value="其他">其他</option>
					</select>
				</span>
				<br />
			</span>
		</div>
		<div style="clear:both;width:100%;">
			<span style="float:right">
			&nbsp;&nbsp;
			按
			<select name="paixu" onchange="getCar('seachpage=$_GET[seachpage]',1);">
				<option $paixumoren value="id desc">默认</option>
				<option $iddaoxu value="id desc">主键降序</option>
				<option $idzhengxu value="id">主键升序</option>
				<option $actdaoxu value="actdate desc">时间降序</option>
				<option $actzhengxu value="actdate">时间升序</option>
			</select>
			排序
			</span>
			<a href="javascript:void(0);" onclick="getCar('',0);" title="查看全部">[全部]</a>
			$seachStatus
		</div>
		</form>
EQT;
			
	/**
	 * ********************************
	 * 是否开启3天用车
	 */
	$threeDay==1?$shantianY=3:$shantianY=1;
	for ($shantian=0;$shantian<$shantianY;$shantian++){
		if ($threeDay==1){
			switch ($shantian){
				case 0:
					$riqi=date("Y-m-d",time());
					echo '<div style="margin-top:8px;font-size:16px;font-weight:bold;">今天（'.$riqi.'）</div>';
					$condition=" and actdate > '".strtotime($riqi)."' and actdate < '".(strtotime($riqi)+INT_DAY)."' ";
					break;
				case 1:
					$ssadfa=time()+INT_DAY;
					$riqi=date("Y-m-d",$ssadfa);
					echo '<div style="margin-top:8px;font-size:16px;font-weight:bold;">明天（'.$riqi.'）</div>';
					$condition=" and actdate > '".strtotime($riqi)."' and actdate < '".(strtotime($riqi)+INT_DAY)."' ";
					break;
				case 2:
					$ssadfa=$ssadfa+INT_DAY;
					$riqi=date("Y-m-d",$ssadfa);
					echo '<div style="margin-top:8px;font-size:16px;font-weight:bold;">后天（'.$riqi.'）</div>';
					$condition=" and actdate > '".strtotime($riqi)."' and actdate < '".(strtotime($riqi)+INT_DAY)."' ";
					break;
			}
		}else{
			$limit=" LIMIT ".($_GET['seachpage']-1)*$pageline." , ".$pageline ;
		}
		//$newTable->alert(strtotime("2008-12-20 00:12:00")-strtotime("2008-12-20"));
		$allCar=Dgs('car_dispatch',"del!=1 ".$condition." order by ".$seachForm[paixu].$limit);
	
	echo <<<EQT
		<form id="selectForm" name="selectForm">
		<table id="cartable" style="text-align:center;">
			<tr class="tthh" >
				<td>NO.</th>
				<td>时间</th>
				<td>项目</th>
				<td>内容</th>
				<td>收费</th>
				<td>城市</th>
				<td>酒店</th>
				<td>客户</th>
				<td>电话</th>
				<td>人数</th>
				<td>车型</th>
				<td>司机</th>
				<td>预定员</th>
				<td>操作</th>
			</tr>
EQT;

		if (is_array($allCar)){
//			Ja(b);
			foreach ($allCar as $carKey => $carValue){
				/**
				 * ***********************************
				 * #新加的,dangtian判断是不是当天的出车!
				 * 时间转换,如果不是搜索的,显示全部时间日期
				 * 搜索的,就只显示后面的时间
				 * ps:$carValue['acting']:0正常,1出-回之间出车(全天),2出车那天(出),3回来那天(回)
				 * 	$carValue['dangtian']:是否是当天出的车:0不是,1是(也就是 不是只有一天)
				 */
				/*
				if ($carValue['dangtian']==0){//是否是当天的出车
					//if ($seachForm['seachDate']==''){//不是搜索状态
						if($carValue['acting']==1){//如果不是在出车及回车的当天,那么说明这一天的时间都 是要被占用.所以,要写上"全天"
							$carValue11='<span style="color:red;font-size:13px;">全天</span><br />'.date("Y-m-d",$carValue['actdate']);
						}else{
							if ($carValue['acting']==2){//出车的状态
								$carValue11='<span style="color:#3A81C8;font-size:13px;">出</span><br />'.date("Y-m-d H:m:s",$carValue['actdate']);
							}else if ($carValue['acting']==3){//回到家的状态
								$carValue11='<span style="color:#3A81C8;font-size:13px;">回</span><br />'.date("Y-m-d H:m:s",$carValue['actdate']);
							}
						}
						$carValue['actdate']=$carValue11;//显示全部
					//}else {
						//$carValue['acting']==0?$carValue['actdate']='<span style="color:red;font-size:13px;">全天</span>':$carValue['actdate']=date("H:m:s",$carValue['actdate']);//只显示时间
					//}
				}else {
					$carValue['actdate']=
						'<span style="color:#008200;font-size:13px;">当天</span><br />
						[出]'.date("Y-m-d H:m:s",$carValue['outdate']).'<br />
						[回]'.date("Y-m-d H:m:s",$carValue['getdate'])
						;//只显示时间
				}
*/
				$carValue['actdateN']='<div>'.date("Y-m-d",$carValue['actdate']).'</div>';
				$carValue['actdateN'].='<div>'.date("H:m:s",$carValue['actdate']).'</div>';
				$carValue[beizhu]=nl2br($carValue[beizhu]);
					echo <<<EQT
					  <label for="car$carValue[gid]">
					  <tr id="$carValue[gid]"  onMouseOut="if($('car$carValue[gid]').checked!=true) this.style.background='';" onMouseOver="if($('car$carValue[gid]').checked!=true) this.style.background='#BDDFFF';">
						<th class="lefttd"><input type="checkbox" id="car$carValue[gid]" name="car" style="border:0;" onClick="$('$carValue[gid]').style.background='#BCE9BE'" value="$carValue[gid]"/>$carValue[id]</th> 
						<td style="font-size:12px;">$carValue[actdateN]</td> 
						<td><a href="javascript:void(0);" onclick="getCar('seachpage=1','xiangmu=$carValue[xiangmu]')" title="搜索项目[$carValue[xiangmu]]">$carValue[xiangmu]</a></td> 
						<td><div style="width:110px;word-wrap: break-word; word-break: normal; ">$carValue[content]</div></td> 
						<td><a href="javascript:void(0);" onclick="getCar('seachpage=1','shoufei=$carValue[shoufei]')" title="搜索收费[$carValue[shoufei]]">$carValue[shoufei]</a></td> 
						<td><a href="javascript:void(0);" onclick="getCar('seachpage=1','chengshi=$carValue[chengshi]')" title="搜索城市[$carValue[chengshi]]">$carValue[chengshi]</a></td> 
						<td><a href="javascript:void(0);" onclick="getCar('seachpage=1','hotel=$carValue[hotel]')" title="搜索酒店[$carValue[hotel]]">$carValue[hotel]</a></td> 
						<td><a href="javascript:void(0);" onclick="getCar('seachpage=1','name=$carValue[name]')" title="搜索客户[$carValue[name]]">$carValue[name]</a></td> 
						<td><a href="javascript:void(0);" onclick="getCar('seachpage=1','tel=$carValue[tel]')" title="搜索客户电话[$carValue[tel]]">$carValue[tel]</a></td> 
						<td><div style="width:70px;white-space:nowrap;">[$carValue[daren]]大[$carValue[xiaohai]]小</div></td>
						<td><a href="javascript:void(0);" onclick="getCar('seachpage=1','chexing=$carValue[chexing]')" title="搜索车型[$carValue[chexing]]">$carValue[chexing]</a></td> 
						<td><a href="javascript:void(0);" onclick="getCar('seachpage=1','siji=$carValue[siji]')" title="搜索司机[$carValue[siji]]">$carValue[siji]</a></td> 
						<td onMouseOut="getDiv('none','beizhu$carValue[gid]');" onMouseOver="getDiv('block','beizhu$carValue[gid]');"><span id="userid$carValue[gid]">$carValue[userid]</span></td> 
						<td><div style="white-space:nowrap;"><a href="javascript:void(0);" onclick="changeInfo('$carValue[gid]','$_GET[seachpage]','$threeDay');">修改</a>  <span class="del"><a href="javascript:void(0);" onclick="if(confirm('您确定要删除吗?')){xajax_delOne('$carValue[gid]','$_GET[seachpage]','$threeDay');}else{return false;}">刪除</a></span></div></td> 
					  </tr>
					  </label>
					  	<script type="text/javascript">
						<!--
							new Tooltip({element: 'userid$carValue[gid]', text: '$carValue[beizhu]'});
						//-->
						</script>
EQT;
					//备注的信息-写在这里,是为了能脱离文档流
					$beizhuMsg.= <<<EQT
							<div id="beizhu$carValue[gid]" style="width:250px;display:none;position: absolute;background:#fff;border:1px solid #3A81C8;z-index:1000;"><div style="background:#3A81C8;color:#fff;text-align:center;">备注:</div><div style="padding:5px;text-align:left;">$carValue[beizhu]</div></div>
EQT;
				}
		}
		echo '</table></form>';
	  		
	}//threeDay end
		$newTable -> assign('beiZhuMsg','innerHTML',$beizhuMsg);
	  echo $delNav;
	  		
	  		
	  $newTableMsg=ob_get_contents();
	  ob_clean();
	$newTable	->	assign('bic_car_1','innerHTML',$newTableMsg);
	return $newTable;
}
//添加新车
function addCar($car){
	$newCar = new xajaxResponse();
	$xiangmuNum=count($car['xiangmuNum']);//一共有几组项目
	$xxc			=	$car;//进行统一管理
	foreach ($xxc as $key => $value){
		if (trim($value)=='' && (strrpos($key,'_')===false)){
			$newCar -> addScript("$('$key').style.border='1px solid red';");
			$newCar -> addScript("setTimeout(\"$('$key').select()\",300);");//选中没填写的input
			$newCar -> addScript("setTimeout(\"$('$key').style.border='1px solid #999'\",3500);");
//			$newCar -> addAppend('newInsert','innerHTML','<div id="msg" class="showMsg" style="z-index:20002;">您的信息还未填写完整,请先补充完整再提交</div>');
			$newCar -> addScript("showMsg('您的信息还未填写完整,请先补充完整再提交');");
			$newCar -> addScript("setTimeout(\"$('msg').parentNode.removeChild($('msg'))\",2000);");//移除上面的div
			$newCar -> addScript("setTimeout(\"closeSub()\",1500);");//解除提交键的锁定
			return $newCar;
		}
	}
	//转换时间
	$xxc['outdate']=strtotime($xxc['outdate']);
	$xxc['getdate']=strtotime($xxc['getdate']);
	$xxj['jidate']=strtotime(date("Y-m-d",$xxc['outdate']));//基时间
	$dayNum=floor((strtotime(date("Y-m-d",$xxc['getdate']))-strtotime(date("Y-m-d",$xxc['outdate'])))/INT_DAY)+1;//时间间隔
	for ($i=1;$i<=$xiangmuNum;$i++){
		$xxc['actdate']		=	strtotime($xxc['actdate_'.$i]);
		$xxc['xiangmu']		=	$xxc['xiangmu_'.$i];
		$xxc['content']		=	$xxc['content_'.$i];
		$xxc['chexing']		=	$xxc['chexing_'.$i];
		$xxc['shoufei']		=	$xxc['shoufei_'.$i];
		$xxc['siji']		=	$xxc['siji_'.$i];
		$xxc['chengshi']	=	$xxc['chengshi_'.$i];
		$xxc['hotel']		=	$xxc['hotel_'.$i];
		$xxc['gid']			=	Bic();
		$xxc['adddate']		=	time();
		Di('car_dispatch',$xxc);//进入
	}
	$newCar -> alert('添加成功,显示 数据已刷新! ');
	$newCar -> addScript("getCar('',0);setTab('car',1,3,0);");
	
	//下面的是把表单清空
	/*
	foreach ($xxc as $key => $value)
	{
		$newCar -> addScript("$('$key').value='';");
	}
	*/
	$newCar -> addScript("closeSub();");//解除提交键的锁定
	return $newCar;
}
//用车信息修改前的回调
function showCar($gid,$page){
	$editCar = new xajaxResponse();
	$tmpInfo=Dga('car_dispatch',"gid='".$gid."'");
	$tmpInfo['actdate']=date("Y-m-d H:m:s",$tmpInfo['actdate']);
	$tmpInfo['getdate']=date("Y-m-d H:m:s",$tmpInfo['getdate']);
	switch ($tmpInfo['acting']){
		case 1:
			$checked1='checked';
			$display1='none';
			$display2='none';
			break;
		case 2:
			$checked2='checked';
			$display1='';
			$display2='none';
			break;
		case 3:
			$checked3='checked';
			$display1='none';
			$display2='';
			break;
		default:
			$checked4='checked';
			$display1='';
			$display2='';
			break;
	}
	switch ($tmpInfo['shoufei']){
		case '标准':
			$showfeiCheck1='checked';
			break;
		case '收费':
			$showfeiCheck2='checked';
			break;
		case '免费':
			$showfeiCheck3='checked';
			break;
	}
	$carInfo= <<<EQT
		<form id="editcar" action="javascript:void(0);" method="POST" class="editcar" style="padding-left:20px;" onSubmit="addCar(this.id,2,$gid,$page);"> <br />
			<label for="name2">客户姓名</label> <input id="name2" type="text"
				name="name" size="20" onblur="checkName(this.id,this.value);" value="$tmpInfo[name]" /> <label for="tel2">联系电话</label> <input
				type="text" id="tel2" name="tel" size="20" value="$tmpInfo[tel]"/><span id="name2checkName" style="margin-left:20px;display:none;"></span><br />
			<label for="daren2">人员組成</label> <input type="text" id="daren2"
				name="daren" size="4" value="$tmpInfo[daren]"/> <label for="daren2">位成年人</label> <input
				type="text" id="xiaohai2" name="xiaohai" size="3" value="$tmpInfo[xiaohai]"/> <label
				for="xiaohai2">位未成年人&nbsp;&nbsp;</label><br />
			<label for="xiangmu2">项&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;目</label> <input type="text" id="xiangmu2"
				name="xiangmu" size="20" value="$tmpInfo[xiangmu]"/><br />
			<label for="content2">内&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;容</label> <textarea
				id="content2" name="content" rows="5" cols="43" />$tmpInfo[content]</textarea><br />
			<br />
			<label for="chexing2">车&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;型</label> <input
				type="text" id="chexing2" name="chexing" size="20" value="$tmpInfo[chexing]"/><br />
			<label for="siji2">司&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;机</label> <input
				type="text" id="siji2" name="siji" size="20" value="$tmpInfo[siji]"/><br />
			<br />
			<label for="chengshi2">出发城市</label> <input type="text"
				id="chengshi2" name="chengshi" size="20" value="$tmpInfo[chengshi]"/><br />
			<label for="hotel2">洒&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;店</label> <input type="text"
				id="hotel2" name="hotel" size="20" value="$tmpInfo[hotel]"/>
			<br />
			<br />
			<label for="actdate2">时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;间</label>
			<input type="text" id="actdate2" name="actdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" size="20" class="Wdate" style="width:158px;height:13px;" value="$tmpInfo[actdate]" />
			<br />
			<label for="shoufei2">收&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;费</label><select id="shoufei2'" name="shoufei"><option $showfeiCheck1 value="标准">标准</option><option $showfeiCheck2 value="收费">收费</option><option $showfeiCheck3 value="免费">免费</option></select>
			<br />
			<!--
				<label for="getdate2">时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;间</label>
				<input id="quantian" name="acting" type="radio" onclick="$('outdateSpan').style.display='none';$('getdateSpan').style.display='none';" $checked1 value="1" title="一整天都用车" style="border:0;"/><label for="quantian">全天</label>
				<input id="chufa" name="acting" type="radio"    onclick="$('outdateSpan').style.display='';$('getdateSpan').style.display='none';" $checked2 value="2" title="出发时间" style="border:0;"/><label for="chufa">出发</label>
				<input id="fanhui" name="acting" type="radio"   onclick="$('outdateSpan').style.display='none';$('getdateSpan').style.display='';" $checked3 value="3" title="返回时间" style="border:0;"/><label for="fanhui">返回</label>
				<input id="chuhui" name="acting" type="radio"   onclick="$('outdateSpan').style.display='';$('getdateSpan').style.display='';" $checked4 value="x" title="又出又回" style="border:0;"/><label for="chuhui">出-返</label><br />
			
			<div id="outdateSpan" style="clear:both;display:$display1;"><label for="outdate2" style="float:left;">出发时间</label> <input type="text" id="outdate2" name="outdate" onfocus="WdatePicker({dateFmt:'yyyy-M-d H:m:s',vel:'d244_2'})" size="20" class="Wdate" style="width:158px;height:13px;" value="$tmpInfo[actdate]" /></div>
			<div id="getdateSpan" style="clear:both;display:$display2;"><label for="getdate2" style="float:left;">返回时间</label> <input type="text" id="getdate2" name="getdate" onfocus="WdatePicker({dateFmt:'yyyy-M-d H:m:s',vel:'d244_2'})" size="20" class="Wdate" style="width:158px;height:13px;" value="$tmpInfo[getdate]" /></div>
			-->
			<br />
			<label for="userid2">预定人员</label> <input type="text" id="userid2"
				name="userid" size="20" value="$tmpInfo[userid]"/> <label for="usertel2">预定员电话</label> <input
				type="text" id="usertel2" name="usertel" size="20" value="$tmpInfo[usertel]"/>
			<br />
			<br />
			<label for="beizhu2">备注</label><br />
			<textarea id="beizhu2" name="beizhu" rows="8" cols="70">$tmpInfo[beizhu]</textarea><br />
			<br />
			<input type="submit" value="Submit this form" style="margin-left:20px;"/> <input type="button"
				value="reset" onclick="clearInp('editcar','Wdate,userid,usertel');" />
	</form>
EQT;
	$editCar -> assign('zhuangtai','innerHTML',$carInfo);
	return $editCar;
}
//修改用车信息
function editCar($car,$gid,$page){
	$editCar = new xajaxResponse();
	$car['actdate']=strtotime($car['actdate']);
	$car['outdate']=strtotime($car['outdate']);
	$car['getdate']=strtotime($car['getdate']);
	switch ($car['acting']){
		case '1':
			break;
		case '2':
			break;
		case '3':
			break;
		case 'x':
			$car['dangtian']=1;
			if (abs($car['getdate']-$car['outdate'])>INT_DAY){
				$editCar->alert('一天中出返的时间不能大于一天!');
				return $editCar;
			}
			break;
	}
	Du('car_dispatch',$car,'gid',$gid);
	//$editCar -> alert("修改成功");
	$editCar -> addScript("getCar('seachpage=$page',1);if(confirm('恭喜您!修改成功!\u000d页面已刷新...\u000d您要关闭\"用车信息修改\"的窗口吗?')){xajax_closeDiv();}");//解除提交键的锁定
	return $editCar;
}
//检查用户是否已存在
function checkName($id,$name){
	$check = new xajaxResponse();
	$tmpName=Dz("select count(*) as num from lm_car_dispatch where 1 and del!=1 and name like '".$name."'");
	$num=$tmpName[0]['num'];
	$xid=$id.'checkName';
	$dmsg='该用户已在本公司租过[<span style="color:red;">'.$num.'</span>]次车';
	$bai='<span style="color:#228F22;">该用户是第一次</span>';
	if ($num>0){
		//$check -> alert($xid);
		$check -> addScript("$('$id').style.color='red';$('$id').style.border='1px solid #3D84CB';");
		$check -> addScript("$('$xid').style.display='';");
		$check -> assign("$xid",'innerHTML',$dmsg);
	}else{
		$check -> addScript("$('$id').style.color='#000';$('$id').style.border='1px solid #999';");
		$check -> assign("$xid",'innerHTML',$bai);
	}
	return $check;
}
//移除div
function closeDiv(){
	$closeD = new xajaxResponse();
	$closeD -> addRemove('act');
	$closeD -> addScript("$('fade').style.display='none';");
	$closeD -> addScript("closeSub();");//解除提交键的锁定
	return $closeD;
}
//单个删除
function delOne($gid,$page,$type=0){
	$delOne = new xajaxResponse();
	$del['del']=1;
	Du('car_dispatch',$del,'gid',$gid);
	$delOne -> addRemove($gid);
	$delOne -> addAppend('newInsert','innerHTML','<div id="msg" class="showMsg">恭喜您,删除成功...</div>');
	if ($type==0){
		$delOne -> addScript("getCar('seachDate=$page','','','');");//刷新分页	
	}else {
		$delOne -> addScript("getCar('seachDate=$page','','','1');");//刷新分页
	}
	$delOne -> addScript("setTimeout(\"$('msg').parentNode.removeChild($('msg'))\",2000);");//移除上面的div	
	return $delOne;
}
//批量删除
function delAll($gid,$page,$type=0){
	$delAll = new xajaxResponse();
	$arr['del']=1;
	//$delAll->alert('删除成功');
	//$delAll->alert($gid[2]);
	foreach ($gid as $k=>$v){
//		$delAll->alert($v);
		Du('car_dispatch',$arr,'gid',$v);
		//$delAll->alert($v);
	}

	$delAll -> addAppend('newInsert','innerHTML','<div id="msg" class="showMsg">恭喜您,删除成功...</div>');
	if ($type==0){
		$delAll -> addScript("getCar('','','','');");//刷新分页	
	}else {
		$delAll -> addScript("getCar('','','','1');");//刷新分页
	}	
	$delAll -> addScript("setTimeout(\"$('msg').parentNode.removeChild($('msg'))\",2000);");//移除上面的div	

	return $delAll;
}


$xajax = new xajax(); 
//$xajax->bDecodeUTF8Input=true;
//$xajax->deBugOn();

$xajax->registerFunction("addCar");
$xajax->registerFunction("delOne");
$xajax->registerFunction("delAll");
$xajax->registerFunction("getCar");
$xajax->registerFunction("showCar");
$xajax->registerFunction("closeDiv");
$xajax->registerFunction("editCar");
$xajax->registerFunction("checkName");
$xajax->processRequests();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Prosperous JIMU</title>
<script language="javascript" type="text/javascript" src="../../jimu/My97/WdatePicker.js"></script>
<script type="text/javascript">
 <!--
	function $(v){
	var a='';
	a=document.getElementById(v);
	if(a!='') return a;
	a==''?a=document.getElementByTagName(v):'';
	if(a!='') return a;
	a==''?a=document.getElementByClassName(v):'';
	return a;
}
 //-->
 </script>
	<?php
        $xajax->printJavascript('/includes/class/xajax/');
    ?>
<style type="text/css">
<!--
* {
	margin: 0;
	padding: 0;
}
body,html{width:100%;height:100%;}
body {
	margin:0 auto;
	text-align: center;
	background-color: #666666;
	font-size: 12px;
	color: #000000;
}
		#tooltip {
			background-color: #ffffcc;
			color: #000000; 
			padding: 4px; 
			border: 1px solid gray; 
			text-align: left; 
			cursor: default;
			opacity: 0.85;
			z-index: 10000;
		}
#newInsert {
	text-align: left;
	width: 93%;
	background-color: #FFFFFF;
	padding: 20px;
	margin:0 auto;
}

#newInsert #title {
	height: 28px;
}

#newInsert #title li {
	float: left;
	list-style-type: none;
	height: 28px;
	line-height: 28px;
	text-align: center;
	margin-right: 1px;
}

#newInsert #title ul {
	background-color: #FFFFFF;
	height: 28px;
}

#newInsert #title a {
	text-decoration: none;
	color: #000000;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-29px;
}

#newInsert #title a span {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-29px;
	padding: 0 15px 0 15px;
}

#newInsert #title #tag1 a:hover {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-87px;
}

#newInsert #title #tag1 a:hover span {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-87px;
	padding: 0 15px 0 15px;
}

#newInsert #title #tag2 a:hover {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left 0px;
}

#newInsert #title #tag2 a:hover span {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		0px;
	padding: 0 15px 0 15px;
}

#newInsert #title #tag3 a:hover {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-58px;
}

#newInsert #title #tag3 a:hover span {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-58px;
	padding: 0 15px 0 15px;
}

#newInsert #title #tag4 a:hover {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-145px;
}

#newInsert #title .selectli1 {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-87px;
}

#newInsert #title a .selectspan1 {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-87px;
	padding: 0 15px 0 15px;
}

#newInsert #title .selectli2 {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left 0px;
}

#newInsert #title a .selectspan2 {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		0px;
	padding: 0 15px 0 15px;
}

#newInsert #title .selectli3 {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-58px;
}

#newInsert #title a .selectspan3 {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-58px;
	padding: 0 15px 0 15px;
}

#newInsert #title .selectli4 {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-145px;
}

#newInsert #title a .selectspan4 {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-145px;
	padding: 0 15px 0 15px;
}

#newInsert #title .selectli5 {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-174px;
}

#newInsert #title a .selectspan5 {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-174px;
	padding: 0 15px 0 15px;
}

#newInsert #title .selectli6 {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-203px;
}

#newInsert #title a .selectspan6 {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-203px;
	padding: 0 15px 0 15px;
}

#newInsert #title .selectli7 {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-232px;
}

#newInsert #title a .selectspan7 {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-232px;
	padding: 0 15px 0 15px;
}

#newInsert #title .selectli8 {
	text-decoration: none;
	color: #ffffff;
	display: block;
	width: auto;
	background: url(../images/tab_selected_left_bk2.gif) no-repeat left
		-261px;
}

#newInsert #title a .selectspan8 {
	display: block;
	background: url(../images/tab_selected_right_bk2.gif) no-repeat right
		-261px;
	padding: 0 15px 0 15px;
}

#newInsert #content ul {
	margin: 10px;
}

#newInsert #content li {
	margin: 5px;
}

#newInsert #content li img {
	margin: 5px;
	display: block;
}

#newInsert #content {
	padding: 10px;
}

.content1 {
	width: 99%;
	border-top-width: 3px;
	border-right-width: 1px;
	border-bottom-width: 1px;
	border-left-width: 1px;
	border-top-style: solid;
	border-right-style: solid;
	border-bottom-style: solid;
	border-left-style: solid;
	border-top-color: #3A81C8;
	border-right-color: #3A81C8;
	border-bottom-color: #3A81C8;
	border-left-color: #3A81C8;
	background-color: #DFEBF7;
}
/*********************************/
#addcar label{
	width:60px;
	display:inline-block;
}

/*********************************/
#cartable{
	width:99%;
	padding: 0;
	margin: 0;
}
.tthh{
	font: bold 17px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	color: #fff;
	height:37px;
	border-right: 1px solid #C1DAD7;
	border-bottom: 1px solid #C1DAD7;
	border-top: 1px solid #C1DAD7;
	letter-spacing: 2px;
	text-transform: uppercase;
	padding:16px 6px 16px 12px;
	background:#3A81C8;
	white-space:nowrap;
}
.tthh td{
	white-space:nowrap;
}
.lefttd{
	font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
	background:#96BBF9;
	height:30px;
}
td{
	border:0;
}

a:link {
	color: #000;
	text-decoration: none
}

a:visited {
	color: #000;
	text-decoration: none;
}

.del a:link{
	color: #f60;
	text-decoration: none
}
.del a:visited{
	color: #f60;
	text-decoration: none
}
.del a:hover {
	color: #f60;
	text-decoration: underline;
}
a:hover {
	color: #f60;
	text-decoration: underline;
}

a:active {
	color: #f39;
	text-decoration: underline;
}

input,textarea {
	border: 1px solid #999999;
}
/*信息提示*/
.showMsg{
	 position:absolute;
	 width:190px;
	 text-align:center;
	 padding:8px 3px;
	 border:1px solid #123;
	 background:#D3D2CF;
	 right:70px;
	 top:150px;
	 color:red;
	 font-size:17px;"
}
		p, span {
			font-size: 14px;
			line-height: 150%;
		}
		span.tip {
			color: #FF6600;
			border-bottom: 1px dashed #FF6600;
		}
/*背景覆盖*/
.blackoverlay{
	display: none;
	position: absolute;
	top: 0%;
	left: 0%;
	width: 100%;
	height: 100%;
	background-color: black;
	z-index:1001;
	filter: alpha(opacity=50);
	-moz-opacity: 0.5;
	opacity:.50;
}
.whitecontent{
	display: none;
	position: absolute;
	top: 25%;
	left: 25%;
	width: 50%;
	height: 50%;
	padding: 16px;
	border: 16px solid orange;
	background-color: white;
	z-index:1002;
	overflow: auto;
}
.showXiangmu label{
	width:13px;
}
/*搜索栏里的input*/
.sssssss{
	width:30px !important;
	width:30px;
}
//-->	
</style>
</head>
<body>
<script type="text/javascript">
<!--

	function changeColor(){
		var msglen=document.getElementsByTagName("input");
		var msglenl=msglen.length;
		for(var i=0;i<msglenl;i++){
		  if (msglen[i].type=="radio" || msglen[i].type=="checkbox"){
			  if(msglen[i].checked==true){
				$(msglen[i].id+'l').style.color='red';
			  }else{
				$(msglen[i].id+'l').style.color='#000';
			  }
		  }
		}
	}
	function getEvent(){     //同时兼容ie和ff的写法

        if(document.all)    return window.event;        

        func=getEvent.caller;            

        while(func!=null){    

            var arg0=func.arguments[0];

            if(arg0){

                if((arg0.constructor==Event || arg0.constructor ==MouseEvent)

                    || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)){    

                    return arg0;

                }

            }

            func=func.caller;

        }

        return null;

}
	//close the submit of input
	function closeSub(){
		//下面的是用于将提交按鍵关闭
		var ai=document.getElementsByTagName("input");
		var ail=ai.length;
		for(var iz=0;iz<ail;iz++){
			//alert(ai[iz].type);
			if(ai[iz].type=="submit") {
				//alert(ai[iz].disabled);
				ai[iz].disabled==false?ai[iz].disabled="disabled":ai[iz].disabled="";
			}
		}
	}
	//clear the input
	function clearInp(i,x)
	{
		var ai=document.forms[i];
		var ail=ai.length;
		var con=new Array();
		con=x.split(',');//限定多个className的查找
		var conl=con.length;
		for(var iz=0;iz<ail;iz++){
			//alert(ai[iz].type);
			if(ai[iz].type=="text") {
				//alert(ai[iz].disabled);
				var is_have;
				is_have=0;//是否含有名字的初始化
				for(var conx=0;conx<conl;conx++){
					//alert(con[conx]);
					if((con[conx]==ai[iz].className || con[conx]==ai[iz].name) && con[conx]!='') is_have=1;
				}
				is_have!=1?ai[iz].value="":'';
			}else if(ai[iz].type=="textarea"){
				ai[iz].value="";
			}
		}
	}
	function changeInfo(i,pg){
		//alert(i);
		//close sub
		closeSub();
		typeof pg == 'undefined'?pg = "":'';
		
		//生成信息载体(div)		
		var newDiv	=	document.createElement("div");
		newDiv.id	=	'act';
		newDiv.innerHTML	=	'<div style="width:100%;background-color:#3A81C8;color:#fff;"><a href="javascript:void(0);" style="float:right;border:1px solid #090;margin:1px 8px 1px 3px;" onMouseOver="this.style.color=red;" onMouseOut="this.style.color==\'#fff\'" onclick="xajax_closeDiv();">关闭</a><span style="float:left;margin-left:41%;font-size:15px;text-align:center;background-color:#3A81C8;">用车信息修改</span></div><div id="zhuangtai" style="clear:both;font-size:13px;overflow:auto;text-align:left;"><img src="/images/ajax-loader.gif" />数据加载中...</div><iframe  style="position:absolute;z-index:-1;width:100%;height:100%;top:0;left:0;scrolling:no;" frameborder="0" src="about:blank">';
		newDiv.style.position="absolute";
		newDiv.style.top="60px";
		newDiv.style.left=(document.body.offsetWidth-650)/2+'px';
		newDiv.style.width="650px";
		//newDiv.style.height="500px";
		newDiv.style.border="1px solid #000";
		newDiv.style.zIndex="1002";
		newDiv.style.overflow="auto";
		//newDiv.onclick=new   Function("alert('正在更新中,目前不可中止...');");
		//newDiv.innerHTML	=	'<div style="margin-top:30px;margin-left:300px;margin-bottom:30px"><img src="/images/ajax-loader.gif" />loading...</div>';
		newDiv.style.background="#fff";
		//this.setDisplayStyle("select",   "hidden");
		

		$('fade').style.display='block';
		//alert($('fade').style.height);
		$('fade').style.height=document.body.clientHeight;
		document.body.appendChild(newDiv);
//alert('b');

		setTimeout("xajax_showCar("+i+","+pg+")",800);
	}
	//按月的即时添加input
	function addMonthDate(){
		var to=$('max');
		var ta=to.getElementsByTagName('input');
		var tl=ta.length;//有几个input
		var endid=tl/2;//最后生成的有效id标识,将会以one开始||		monthDate及price做基准
		//alert(tl);
		//alert(endid);
		if(endid>=28){
			alert('最大设置数量为28个,您已经为最大了...');
			return false;
		}
		var newSpan=document.createElement("span");
		newSpan.id='one'+endid;
		newSpan.className="setdate";
			newSpan.innerHTML='<div class="at up">							<input type="text" id="monthDate'+endid+'" name="monthDate'+endid+'" value="" style="text-align:center;"  size="3"/>号&nbsp;&nbsp;						</div>						<div class="at down">							<input type="text" name="price'+endid+'" size="6" style="text-align:center;" />:(元)						</div>';

		//to.parentNode.removeChild($('one'));
		to.appendChild(newSpan);
		//document.body.appendChild(newSpan);
	}
	if (document.all){
//	 window.attachEvent('onload',xajax_getCar)//对于IE
	}
	else{
//	 window.addEventListener('load',xajax_getCar,false);//对于FireFox
	}

	var ched;
	ched=true;
	var all=new Array;
	function chkall(input1,input2)
	{
		//alert(input2);
		var objForm = document.forms[input1];
		var objLen = objForm.length;
		for (var iCount = 0; iCount < objLen; iCount++)
		{
			if (ched == true)
			{
				if (objForm.elements[iCount].type == "checkbox")
				{
					objForm.elements[iCount].checked = true;
					$(objForm.elements[iCount].value).style.background='#BCE9BE';
				}

			}
			else
			{
				if (objForm.elements[iCount].type == "checkbox")
				{
					objForm.elements[iCount].checked = false;
					$(objForm.elements[iCount].value).style.background='';
				}
			}
		//alert(all.length);
		}
		if(ched==true){
			ched=false;
			$('actselect').innerHTML='全(取消)';
			$('actselect').style.color='#35682C';
		}else{
			ched=true;
			$('actselect').innerHTML='全(选中)';
			$('actselect').style.color='#02418A';
		}
	}
	function delAll(io){
		//alert(all.length);
		all=new Array;//初始化
		var objForm = document.forms[io];
		var objLen = objForm.length;
		for (var iCount = 0; iCount < objLen; iCount++)
		{
				if (objForm.elements[iCount].type == "checkbox")
				{
					if(objForm.elements[iCount].checked == true) {
						all[iCount]=objForm.elements[iCount].value;
					}
				}
		//alert(all.length);
		}
		ched=true;//初始化全选变量
		xajax_delAll(all);
	}
	
	
	//tab
	function setTab(name,cursel,n,o){
	 for(i=1;i<=n;i++){
	  var menu=document.getElementById(name+i);
	  var menu2=document.getElementById(name+i+'_'+i);
	  var con=document.getElementById("bic_"+name+"_"+i);
	  //alert(menu.className);
	  menu.className=i==cursel?"selectli1":"";
	  menu2.className=i==cursel?"selectspan1":"";
	  o==0?(con.style.display=i==cursel?"block":"none"):'';
	 }
	}
	function getCar(pagena,isseach,seachF,threeDay){
//		alert(typeof pagena);
//		alert(typeof seachF);
//		alert(typeof seachD);
//		alert(typeof seachN);
//		alert(typeof seachT);
		var lsj=new Array();
		typeof pagena == 'undefined'?pagena = "":'';
		typeof isseach == 'undefined'?isseach = 1:'';
		seachFs=xajax.getFormValues('searchCar');
		if(typeof seachF == 'undefined'){
			seachF=seachFs;//每次都获取搜索表单的内容
		}else{
			lsj=seachF.split('=');
			seachFs[lsj[0]]=lsj[1];
			seachF=seachFs;//每次都获取搜索表单的内容
		}
		typeof threeDay == 'undefined'?threeDay = "":'';
//		typeof seachN == 'undefined'?seachN = "":'';
//		typeof seachT == 'undefined'?seachT = "":'';
//		alert(typeof pagena);
		//alert(isseach);

		//生成信息载体(div)		
		var newDiv8	=	document.createElement("div");
		newDiv8.id = 'new2sdf';
		newDiv8.style.margin='30px 0 30px 300px';
		newDiv8.innerHTML	=	'<img src="/images/ajax-loader2.gif" />loading...';

		var   o   =   document.getElementsByTagName("form"); 
		var od='';
		for   (var   i=0;   i<o.length;   i++)  
		{  
			o[i].name=='selectForm'?od='y':'';
		}
		od=='y'?$('selectForm').parentNode.replaceChild(newDiv8,$('selectForm')):'';
		 
		setTimeout("xajax_getCar('"+pagena+"','"+isseach+"','"+seachF+"','"+threeDay+"')",1300);
	}

	setTimeout("getCar('',0,'jingjian=jingjian',1);setTab('car',3,3,1);",300);

	function mouseCoords(ev) 
	{ 
	if(ev.pageX || ev.pageY){
	return {x:ev.pageX, y:ev.pageY}; 
	} 
	return { 
	x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, 
	y:ev.clientY + document.documentElement.scrollTop 
	}; 
	} 
	//跟着鼠标跑
	function getDiv(obj,i)
	{
	
	  $(i).style.display=obj;
	  var mousePos = mouseCoords(getEvent());
//	  alert(getEvent().clientY+30+document.body.scrollTop);
//	  alert(getEvent().clientY);
//	  alert(window.screen.height);
	  if(getEvent().clientY+90<window.screen.height/2){
		  $(i).style.top=mousePos.y+30+'px';
		  }else{
			  $(i).style.top=mousePos.y-$(i).clientHeight-30+'px';
			  }
	  $(i).setAttribute=("style",top);
//	  alert($(i).style.top);
			  
	  if(getEvent().clientX-160<document.body.offsetWidth/2){
	 	$(i).style.left=getEvent().clientX+15+document.body.scrollLeft+'px';
	  }else{
		  $(i).style.left=getEvent().clientX-265+document.body.scrollLeft+'px';
	  }
	
	 
	}

	function showMsg(msg){
		//<div id=\"msg\" class=\"showMsg\" style=\"z-index:20002;\">您的信息还未填写完整,请先补充完整再提交</div>
		var newDiv	=	document.createElement("div");
		newDiv.id	=	'msg';
		newDiv.className='showMsg';
		newDiv.innerHTML=msg;
		newDiv.style.position="absolute";
		newDiv.style.zIndex="20002";
		newDiv.style.background="#fff";
 
		document.body.appendChild(newDiv);
		  var eleStyle = document.getElementById("msg").style;
		  window.onscroll = function()
		                    {
		                      eleStyle.top = document.documentElement.scrollTop + 50 + "px";
		                    }
	}

	function getDay(nextm){
		switch (nextm) {
        case 1:
          day = 31;
          break;
        case 3:
          day = 31;
          break;
        case 5:
          day = 31;
          break;
        case 7:
          day = 31;
          break;
        case 8:
          day = 31;
          break;
        case 10:
          day = 31;
          break;
        case 12:
          day = 31;
          break;
        case 4:
          day = 30;
          break;
        case 6:
          day = 30;
          break;
        case 9:
          day = 30;
          break;
        case 11:
          day = 30;
          break;
        case 2:
          if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            day = 29;
          }  else {
              day = 28;
            }
        }
        return day;
	}

	function showXiangmu(){
		var od=$('outdate').value;
		var oa=new Array();
		var oa=od.split('-');
		var nexty=parseInt(oa[0]);
		var nextm=parseInt(oa[1]);
		var nextd=parseInt(oa[2]);
		var ot=new Date(parseInt(oa[0]),parseInt(oa[1])-1,parseInt(oa[2]));
        
		
		var gd=$('getdate').value;
		var ga=new Array();
		var ga=gd.split('-');
		var gt=new Date(parseInt(ga[0]),parseInt(ga[1])-1,parseInt(ga[2]));
		var num=(gt.getTime()-ot.getTime())/86400000+1;
		//num>0?$('showXiangmu').style.border='1px solid #fff;':$('showXiangmu').style.border='0;';
		//alert(num);

		//获取原有项目数目
		var oldNum=$('showXiangmu').getElementsByTagName('span').length;
		//alert(oldNum);
		//清除多作的项目
		if(num<oldNum){
			for(var x=1;x<=oldNum;x++){
				if(x>num){
					$('showXiangmu').removeChild($('newXlig['+x+']'));
				}
			}
		}else if(num>oldNum){//添加新的项目
			if(oldNum>0){
				var nd=$('actdate_'+oldNum).value;
				var na=new Array();
				var na=nd.split(' ');
				var na=na[0].split('-');
				var nt=new Date(parseInt(na[0]),parseInt(na[1])-1,parseInt(na[2]));
				var nexty=parseInt(na[0]);
				var nextm=parseInt(na[1]);
				var nextd=parseInt(na[2])+1;
			}
			day=getDay(nextm);
	        if(nextd>day){
	        	nextm++;
	        	nextd=1;
	        }
	        if(nextm>12){
	        	nexty++;
	        	nextm=1;
	        }
			for(var i=oldNum+1;i<=num;i++){
				day=getDay(nextm);
				var zz=document.createElement('span');
				zz.id='newXlig['+i+']';
				zz.style.width="90%";
				zz.style.float="left";
				zz.style.display="block";
				zz.style.borderBottom="2px solid #B2BBCA";
				zz.style.paddingTop="13px";
				zz.style.paddingBottom="3px";
				zz.innerHTML='<input type="hidden" name="xiangmuNum['+i+']" /><label for="actdate_'+i+'">时间</label><input id="actdate_'+i+'" name="actdate_'+i+'"	onfocus="WdatePicker({dateFmt:\'yyyy-MM-dd HH:mm:ss\',minDate:\''+nexty+'-'+nextm+'-'+nextd+' 00:05:05\',maxDate:\''+nexty+'-'+nextm+'-'+nextd+' 23:55:55\'})" class="Wdate" style="height:13px;" size="25" value="'+nexty+'-'+nextm+'-'+nextd+' 08:08:08"/><label for="xiangmu_'+i+'" style="width:21px;white-space:nowrap;">项目</label><select id="xiangmu_'+i+'" name="xiangmu_'+i+'"><option value="接机">接机</option><option value="送机">送机</option><option value="旅游">旅游</option>	<option selected value="其他">其他</option></select><label for="contents_'+i+'">内容</label><input id="contents_'+i+'" name="content_'+i+'" size="37"/><br /><label for="chexing_'+i+'">车型</label><input	type="text" id="chexing_'+i+'" name="chexing_'+i+'" size="15" /><label for="siji_'+i+'" style="width:21px;white-space:nowrap;">司机</label> <input type="text" id="siji_'+i+'" name="siji_'+i+'" size="15" /><label for="chengshi_'+i+'" style="width:21px;white-space:nowrap;">出发城市</label> <input type="text" 	id="chengshi_'+i+'" name="chengshi_'+i+'" size="15" /><label for="hotel_'+i+'" style="width:21px;white-space:nowrap;">洒店</label><input type="text"	id="hotel_'+i+'" name="hotel_'+i+'" size="15" /><label for="shoufei_'+i+'" style="width:21px;white-space:nowrap;">收费</label><select id="shoufei_'+i+'" name="shoufei_'+i+'"><option selected value="标准">标准</option><option value="收费">收费</option><option value="免费">免费</option></select><br />';
				$('showXiangmu').appendChild(zz);

				//时间加加
		        nextd++;
		        if(nextd>day){
		        	nextm++;
		        	nextd=1;
		        }
		        if(nextm>12){
		        	nexty++;
		        	nextm=1;
		        }
			}
		}


	}

	

	//-->
</script>
<div id="newInsert">
<div id="title">
<ul>
	<li onClick="if($('car3').className!=''){getCar('',0);}setTab('car',1,3,0);"><a id="car1" class="selectli1" href="javascript:void(0);"><span id="car1_1" class="selectspan1">用车计划</span></a></li>
	<li onClick="setTab('car',2,3,0);"><a id="car2" class="" href="javascript:void(0);"><span id="car2_2">添加用车</span></a></li>
	<li onClick="getCar('',0,'',1);setTab('car',3,3,1);"><a id="car3" class="" href="javascript:void(0);"><span id="car3_3">三天用车</span></a></li>
</ul>
</div>
<div id="content" class="content1">
<div id="showDate"
	style="min-width: 30px !important; width: 100%; position: relative;">

	<div id="bic_car_1"><!--*********************车辆调度系統*************************-->
		<div><img src="/images/ajax-loader2.gif" />数据加载中...</div>

	</div>

	<!--************************添加*********************************//-->
	<script langues="javascript" type="text/javascript">
	<!--
	function addCar(i,t,g,p){
		switch(t){
		case 1:
			closeSub();
			xajax_addCar(xajax.getFormValues(i));
			break;
		case 2:
			xajax_editCar(xajax.getFormValues(i),g,p);
			break;
		}
	}
	function checkName(id,name){
		xajax_checkName(id,name);
	}
	//-->
	</script>

	<div id="bic_car_2" style="display: none;">

	<form id="addcar" action="javascript:void(0);" method="POST" class="addcar" onSubmit="addCar(this.id,1,'');">
			<br />
			<label for="namex">客户姓名</label> <input id="namex" type="text" name="name" size="20" onblur="checkName(this.id,this.value);" value="" /> <label for="tel">联系电话</label> <input type="text" id="tel" name="tel" size="20" /><span id="namexcheckName" style="margin-left:20px;display:none;"></span><br />
			<label for="daren">人员組成</label> <input type="text" id="daren" name="daren" size="4" /> <label for="daren">位成年人</label> <input type="text" id="xiaohai" name="xiaohai" size="3" /> <label for="xiaohai">位未成年人</label><br />
			
			<label for="outdate">离开时间</label> <input type="text" id="outdate" name="outdate"	onfocus="WdatePicker({minDate:'%y-%M-#{%d}'})" size="20" class="Wdate" style="width:108px;height:13px;" onchange="$('getdate').value='';$('showXiangmu').innerHTML='';" value="<?php echo date("Y-m-d",time()); ?>" /><br />
			<label for="getdate">返回时间</label> <input type="text" id="getdate" name="getdate"	onfocus="WdatePicker({dateFmt:'yyyy-M-d',vel:'d244_2',minDate:'#F{$dp.$D(\'outdate\')}'})" size="20" class="Wdate" style="width:108px;height:13px;" onchange="showXiangmu();" value="" /> <br />
			<br />
			<div id="showXiangmu" class="showXiangmu" style="clear:both;"></div>
			<label for="userid">预定人员</label> <input type="text" id="userid" name="userid" size="20" value="<?php echo $_SESSION['userinfo']['user']?>"/> <label for="usertel">预定员电话</label> <input type="text" id="usertel" name="usertel" size="20" /> <br />
			<label for="beizhu">备注</label><br />
			<textarea id="beizhu" name="beizhu" rows="8" cols="70"></textarea><br />
			<br />
			<input type="submit" value="Submit this form" /> <input type="button" value="reset" onclick="clearInp('addcar','Wdate,userid,usertel');" />
	</form>

	</div>
	</div>
<script langues="javascript" type="text/javascript">
<!--
//$(document).ready(function(){$('addcar').build()});
//-->
</script>
</div>
</div>

<!--<p>This is the main content. To display a lightbox click <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block'">here</a></p>
<div id="light" class="whitecontent" style="display: none;position: absolute;top: 25%;left: 25%;width: 50%;height: 50%;padding: 16px;border: 16px solid orange;background-color: white;z-index:1002;overflow: auto;">This is the lightbox content. <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>

-->
<div id="fade" class="blackoverlay" style="	display: none;position: absolute;top: 0%;left: 0%;width: 100%;height: 100%;background-color: black;z-index:1001;filter: alpha(opacity=50);-moz-opacity: 0.5;opacity:.50;"></div>
<div id="beiZhuMsg"></div>
</body>
</html>
